﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.Infrastructure;
using DLM.Domain.Model;

namespace DLM.Data.EF.CodeFirst.Mapping
{
    public class UserPartyAssociationMap : EntityTypeConfiguration<UserPartyAssociation>
    {
        public UserPartyAssociationMap()
        {
            this.HasKey(t => t.UPAID);
            this.ToTable("UserPartyAssociation");
            this.Property(t => t.UPAID).HasColumnName("UPAID");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.PartyID).HasColumnName("PartyID");
            this.Property(t => t.IsLead).HasColumnName("IsLead");
            this.Property(t => t.AssociationDate).HasColumnName("AssociationDate");
            this.HasRequired(t => t.Party).WithMany(t => t.UserPartyAssociation).HasForeignKey(d => d.PartyID);
            this.HasRequired(t => t.User).WithMany(t => t.UserPartyAssociation).HasForeignKey(d => d.UserID);
            //this.Ignore(t => t.Id);
        }
    }
}
